/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.examenes.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.isn.atencionemergencia.entity.OrdenDeAtencionDeEmergencia;
import com.isn.logueo.entity.Usuario;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "orden_de_examenes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdenDeExamenes.findAll", query = "SELECT o FROM OrdenDeExamenes o"),
    @NamedQuery(name = "OrdenDeExamenes.findByNumOe", query = "SELECT o FROM OrdenDeExamenes o WHERE o.numOe = :numOe"),
    @NamedQuery(name = "OrdenDeExamenes.findByFechaOe", query = "SELECT o FROM OrdenDeExamenes o WHERE o.fechaOe = :fechaOe"),
    @NamedQuery(name = "OrdenDeExamenes.findByEstadoOe", query = "SELECT o FROM OrdenDeExamenes o WHERE o.estadoOe = :estadoOe"),
    @NamedQuery(name = "OrdenDeExamenes.findByTipOpe", query = "SELECT o FROM OrdenDeExamenes o WHERE o.tipOpe = :tipOpe")})
public class OrdenDeExamenes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Num_Oe", columnDefinition="CHAR(5) unsigned")
    private String numOe;
    @Column(name = "Fecha_Oe")
    @Temporal(TemporalType.DATE)
    private Date fechaOe;
    @Column(name = "Estado_Oe")
    private String estadoOe;
    @Basic(optional = false)
    @Column(name = "tip_ope")
    private String tipOpe;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenDeExamenes")
    private Collection<DetalleOrdenexamen> detalleOrdenexamenCollection;
    @JoinColumn(name = "Num_Oae", referencedColumnName = "Num_Oae")
    @ManyToOne(optional = false)
    private OrdenDeAtencionDeEmergencia numOae;
    @JoinColumn(name = "Usuario", referencedColumnName = "Usuario")
    @ManyToOne(optional = false)
    private Usuario usuario;

    public OrdenDeExamenes() {
    }

    public OrdenDeExamenes(String numOe) {
        this.numOe = numOe;
    }

    public OrdenDeExamenes(String numOe, String tipOpe) {
        this.numOe = numOe;
        this.tipOpe = tipOpe;
    }

    public String getNumOe() {
        return numOe;
    }

    public void setNumOe(String numOe) {
        this.numOe = numOe;
    }

    public Date getFechaOe() {
        return fechaOe;
    }

    public void setFechaOe(Date fechaOe) {
        this.fechaOe = fechaOe;
    }

    public String getEstadoOe() {
        return estadoOe;
    }

    public void setEstadoOe(String estadoOe) {
        this.estadoOe = estadoOe;
    }

    public String getTipOpe() {
        return tipOpe;
    }

    public void setTipOpe(String tipOpe) {
        this.tipOpe = tipOpe;
    }

    @XmlTransient
    public Collection<DetalleOrdenexamen> getDetalleOrdenexamenCollection() {
        return detalleOrdenexamenCollection;
    }

    public void setDetalleOrdenexamenCollection(Collection<DetalleOrdenexamen> detalleOrdenexamenCollection) {
        this.detalleOrdenexamenCollection = detalleOrdenexamenCollection;
    }

    public OrdenDeAtencionDeEmergencia getNumOae() {
        return numOae;
    }

    public void setNumOae(OrdenDeAtencionDeEmergencia numOae) {
        this.numOae = numOae;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numOe != null ? numOe.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenDeExamenes)) {
            return false;
        }
        OrdenDeExamenes other = (OrdenDeExamenes) object;
        if ((this.numOe == null && other.numOe != null) || (this.numOe != null && !this.numOe.equals(other.numOe))) {
            return false;
        }
        return true;
    }



	

}
